<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>

		<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
		<style>
			#loginForm {

				background-color: lightblue;
				width: 300px;
				margin: 200px auto;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<div id="loginForm" v-if="!isLogin">
				<h1 style="text-align: center;">用户注册</h1>
				<div>用户名:<input type="text" v-model="regitserInfo.username" /></div>
				<div>密码:<input type="password" v-model="regitserInfo.password" /></div>
				<div>重复密码:<input type="repassword" v-model="regitserInfo.repassword" /></div>
				<div>用户性别:
					<input type="radio" v-model="regitserInfo.gender" value="1">男
					<input type="radio" v-model="regitserInfo.gender" value="2">女
				</div>
				<div>
					爱好:
					<input type="checkbox" value='听音乐' v-model="regitserInfo.likes" />听音乐
					<input type="checkbox" value='唱歌' v-model="regitserInfo.likes" />唱歌
					<input type="checkbox" value='打游戏' v-model="regitserInfo.likes" />打游戏
					<input type="checkbox" value='看电影' v-model="regitserInfo.likes" />看电影
				</div>
				<div>
					学历：
					<select v-model="regitserInfo.work">
						<option disabled value="">请选择你的学历</option>
						<option>小学</option>
						<option>初中</option>
						<option>高中</option>
						<option>大专</option>
						<option>本科</option>
						<option>研究生</option>
					</select><br />
				</div>
				<div>
					用户简介：
					<textarea v-model="regitserInfo.message" rows="10" cols="40"></textarea>
					<br />
				</div>
				<div>
					<input type="checkbox" value='同意用户协议' v-model="regitserInfo.likes" />同意用户协议
				</div>
				<div><button @click="login">注册</button></div>
			</div>
			<div v-else>
				{{username}}已登录<br />
				<div><button @click="loginOut">登出</button></div>
			</div>
		</div>



		<script>
			var app = Vue.createApp({
				data() {
					return {
						regitserInfo: {
							username: '',
							password: '',
							repassword: '',
							gender: '',
							likes: '',
							work: '',
							message: ''
						}
						username: '',
						password: '',
						isLogin: false
					}
				},
				methods: {
					login: function() {
						if (this.username == "admin" && this.password == "123") {
							alert("注册成功")
							this.isLogin = true
						} else {
							alert("注册失败")
						}
					},
					loginOut: function() {
						this.isLogin = false;
					}
				}
			});
			var vm = app.mount("#app")
		</script>



	</body>
</html>